package cn.edu.jxust.common.domain.web.api.enterprise;

import cn.edu.jxust.common.domain.dto.TradeTypeVo;
import cn.edu.jxust.common.response.Result;
import cn.edu.jxust.core.infrastructure.util.Const;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author QiuKangming
 * @version 1.0
 * @description
 * @since 2020/09/15 15:06
 */
@RequestMapping("/api/trade")
public interface ITradeTypeController {

    /**
     * 查询所有记录
     * @param page 第几页
     * @param size 一页几条数据
     * @return Result
     */
    @GetMapping
    @RequiresPermissions("tradetype:list")
    Result getAllTradeType(@RequestParam(value = "page",defaultValue = Const.DEFAULT_PAGE_NUMBER) Integer page,
                           @RequestParam(value = "size",defaultValue = Const.DEFAULT_PAGE_SIZE) Integer size);

    /**
     * 根据id查询行业类型
     * @param id 行业类型id号
     * @return Result
     */
    @GetMapping("/{id}")
    @RequiresPermissions("tradetype:list")
    Result getOneTradeType(@PathVariable("id") @Validated Integer id);

    /**
     * 添加一条行业类型记录
     * @param tradeTypeVo 行业类型视图对象
     * @param result 绑定视图对象
     * @return Result
     */
    @PostMapping
    @RequiresPermissions("tradetype:add")
    Result addOneTradeType(@RequestBody TradeTypeVo tradeTypeVo, BindingResult result);

    /**
     * 修改行业类型数据
     * @param tradeTypeVo 行业类型视图对象
     * @param result 绑定视图对象
     * @return Result
     */
    @PutMapping
    @RequiresPermissions("tradetype:edit")
    Result updateOneTradeType(@RequestBody TradeTypeVo tradeTypeVo, BindingResult result);

    /**
     * 根据id删除一条行业类型记录
     * @param id 行业类型id号
     * @return Result
     */
    @DeleteMapping("/{id}")
    @RequiresPermissions("tradetype:del")
    Result deleteOneTradeType(@PathVariable("id") @Validated Integer id);
}
